﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace MixScriptWeb.Accounting.ReportFinnance
{
    public partial class frmIncomeStatement : cCommonWeb, IMIxCommon // System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                LoadData();
        }
        private void LoadData()
        {
            FillDropDownList(ddlCurrency, "mst_currency", "currency", "currency", true);

            for (int i = 0; i < ddlPeriod.Items.Count; i++)
            {
                ddlPeriod.Items[i].Text = ddlPeriod.Items[i].Text + ' ' + (DateTime.Now.Year).ToString();
            }
        }

        protected void ddlTipePeriode_selectedIndexChange(Object Sender, EventArgs e)
        {
            List<ListItem> ols = new List<ListItem>();
            if (ddlTipePeriode.SelectedItem.Value == "0")
            {
                ols.Add(new ListItem("January", "1"));
                ols.Add(new ListItem("February", "2"));
                ols.Add(new ListItem("March", "3"));
                ols.Add(new ListItem("April", "4"));
                ols.Add(new ListItem("May", "5"));
                ols.Add(new ListItem("July", "6"));
                ols.Add(new ListItem("June", "7"));
                ols.Add(new ListItem("August", "8"));
                ols.Add(new ListItem("September", "9"));
                ols.Add(new ListItem("October", "10"));
                ols.Add(new ListItem("November", "11"));
                ols.Add(new ListItem("December", "12"));
            }
            else if (ddlTipePeriode.SelectedItem.Value == "1")
            {
                ols.Add(new ListItem("January-March", "1,2,3"));
                ols.Add(new ListItem("April-June", "4,5,6"));
                ols.Add(new ListItem("July-September", "7,8,9"));
                ols.Add(new ListItem("October-December", "10,11,12"));
            }
            else if (ddlTipePeriode.SelectedItem.Value == "2")
            {
                ols.Add(new ListItem("January-June", "1,2,3,4,5,6"));
                ols.Add(new ListItem("July-December", "7,8,9,10,11,12"));
            }
            else if (ddlTipePeriode.SelectedItem.Value == "3")
            {
                ols.Add(new ListItem((DateTime.Now.Year - 1).ToString(), (DateTime.Now.Year - 1).ToString()));
                ols.Add(new ListItem((DateTime.Now.Year).ToString(), (DateTime.Now.Year).ToString(), true));
                ols.Add(new ListItem((DateTime.Now.Year + 1).ToString(), (DateTime.Now.Year + 1).ToString()));
            }

            ddlPeriod.DataSource = ols;
            ddlPeriod.DataBind();

            if (ddlTipePeriode.SelectedItem.Value != "3")
            {
                for (int i = 0; i < ddlPeriod.Items.Count; i++)
                {
                    ddlPeriod.Items[i].Text = ddlPeriod.Items[i].Text + ' ' + (DateTime.Now.Year).ToString();
                }
            }

        }
        public bool isvalid()
        {
            return true;
        }
        protected void btnProcess_Click(object sender, EventArgs e)
        {
            Session["Period"] = ddlPeriod.SelectedItem.Text;
            Session["Cur"] = ddlCurrency.SelectedItem.Text;

            ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW",
                    "window.open( '/Accounting/ReportFinnance/IncomingStatment_Rpt.aspx', null, '' );", true);

        }
    }
}